﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data.OleDb;

namespace Sicurezza.CA.DataProvider
{
    public class CrlDataProvider
    {
        public int Save()
        {
            int serial = 0;

            using (OleDbConnection conn = new OleDbConnection(ConnectionStringDataProvider.ConnectionString))
            {
                conn.Open();

                string query = "INSERT INTO Crl " +
                                "([Timestamp]) " +
                                "VALUES (#" + DateTime.Now.ToString("yyyy-MM-dd hh:mm:ss") + "#)";

                OleDbCommand cmd = new OleDbCommand(query, conn);

                cmd.ExecuteNonQuery();

                cmd.CommandText = "SELECT @@Identity";
                serial = Convert.ToInt32(cmd.ExecuteScalar());

            }

            return serial;
        }
    }
}
